<template>
    <div>
        <div class="top">
            <div class="title"
                 v-show="!($store.state.parentDefaultShow || (!$store.state.parentDefaultShow && $store.state.childDefaultShow)) || listShow">
                考核评分</div>
            <div class="wrap_select select" v-if="selectShow">
                <el-button-group>
                    <el-button type="primary" :selected="selected" @click="selectDeal(true)">
                        <i class="iconfont icon-moxing"></i>模型
                    </el-button>
                    <el-button type="primary" :selected="!selected" @click="selectDeal(false)">
                        <i class="iconfont icon-gengduo"></i>列表
                    </el-button>
                </el-button-group>
            </div>
        </div>
        <!--<div class="navigation">
				<el-button :selected="navigationIndex === 0" @click="navigationSelect(0, 'demolition-manage')">拆迁管理</el-button>
			</div>-->
        <div class="wrap_model" v-show="modelShow">
            <!--                  <iframe src="http://192.168.17.156:8081/hls.html?token=401&autoplay=true"></iframe>-->
<!--            <img class="wrap_model_pic" src="../../../../static/images/login/wtgl.png" width="100%" height="100%">-->
        </div>

        <div class="wrap_list" v-show="listShow">
            <keep-alive>
                <!-- <router-view
					v-show="!($store.state.parentDefaultShow || (!$store.state.parentDefaultShow && $store.state.childDefaultShow))"></router-view> -->
                <router-view></router-view>
            </keep-alive>
        </div>
    </div>
</template>

<script>
export default {
    name: "checknotice",
    data () {
        return {
            selected: this.$store.state.asideClick ? false : true,
            navigationIndex: 0,
            selectShow: false, // 切换按钮显隐
            modelShow: false, // 模型显隐
            listShow: false, // 列表显隐
        }
    },
    watch: {
        // 监听路由 设置子导航
        /*'$route' (newPath, oldPath) {
				switch (newPath.name) {
						case 'checknotice-manage': case 'checknotice-manage-detail':
								this.navigationIndex = 0
								break
				}
		}*/
    },
    created () {
        /*// 监听路由 设置子导航
		switch (this.$route.name) {
				case 'checknotice-manage': case 'checknotice-manage-detail':
						this.navigationIndex = 0
						break
		}*/
    },
    mounted () {
        // 加载时判断模型列表的显隐关系
        setTimeout(this.loadDealModelList, 50)
    },
    methods: {
        // 加载时判断模型列表的显隐关系
        loadDealModelList () {
            let routeActive = this.$route.meta.active
            for (let i in this.$store.state.allNavigations) {
                let item = this.$store.state.allNavigations[i]
                if (routeActive[0].toString() === item.index) {
                    //  item.default = true
                    // item.model=true
                    console.log(item.model, item.default)
                    // 是否有模型
                    this.$store.state.modelShow = item.model
                    if (item.model) {
                        // 显示按钮
                        this.selectShow = true
                        // 是否点击了左侧菜单
                        if (this.$store.state.asideClick) {
                            // 隐藏模型
                            this.modelShow = false
                            // 显示左侧 列表
                            this.$store.state.asideShow = true
                            this.listShow = true
                            return
                        }
                        // 是否显示缺省图
                        if (item.default) {
                            this.$store.state.parentDefault = true
                            // 隐藏模型
                            this.modelShow = false
                            // 隐藏左侧 列表
                            this.$store.state.asideShow = false
                            this.listShow = false
                        } else {
                            this.$store.state.parentDefault = false
                            // 显示模型
                            this.modelShow = true
                            // 隐藏左侧 列表
                            this.$store.state.asideShow = false
                            this.listShow = false
                        }
                    } else {
                        // 隐藏按钮
                        this.selectShow = false
                        // 隐藏模型
                        this.modelShow = false
                        // 隐藏左侧 列表
                        if (!this.$route.meta.asideHide) {
                            this.$store.state.asideShow = true
                        } else {
                            this.$store.state.asideShow = false
                        }
                        this.listShow = true
                    }
                    break
                }
            }
        },
        // 点击选择模型列表按钮切换
        selectDeal (flag) {
            if (this.selected !== flag) {
                this.selected = !this.selected
            }
            let routeActive = this.$route.meta.active
            this.$store.state.allNavigations.forEach(item => {
                if (routeActive[0].toString() === item.index) {
                    // 如果是模型
                    if (flag) {
                        this.$store.state.asideClick = false
                        // 是否显示缺省图
                        if (item.default) {
                            // 隐藏模型
                            this.modelShow = false
                            // 隐藏左侧 列表
                            this.$store.state.asideShow = false
                            this.listShow = false
                        } else {
                            // 显示模型
                            this.modelShow = true
                            // 隐藏左侧 列表
                            this.$store.state.asideShow = false
                            this.listShow = false
                        }
                    } else {
                        // 隐藏模型
                        this.modelShow = false
                        // 隐藏左侧 列表
                        if (!this.$route.meta.asideHide) {
                            this.$store.state.asideShow = true
                        } else {
                            this.$store.state.asideShow = false
                        }
                        this.listShow = true
                    }
                }
            })
        },
        navigationSelect (index, name) {
            this.navigationIndex = index
            // 跳转到对应的路由
            this.$goRoute(name)
        }
    }
}
</script>

<style scoped lang="scss">
.top {
  width: 100%;
  height: 40px;
  margin-top: 10px;

  .title {
    float: left;
    font-family: PingFangSC-Regular;
    font-size: 18px;
    font-weight: 600;
  }

  .select {
    float: right;

    .el-button {
      height: 40px;
      font-family: PingFangSC-Regular;
      font-size: 14px;
      color: #CAD4DF;
      letter-spacing: 0;
      border-radius: 6px;

      &[selected] {
        background: #fff;
        color: #041626;
        border: 1px solid #fff;
      }

      &:first-child {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
      }

      &:last-child {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
      }

      i {
        font-size: 14px;
        margin-right: 6px;
      }
    }
  }
}

.navigation {
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  border-bottom: 1px solid #313E50;
  margin-top: 5px;

  .el-button {
    height: 40px;
    background: #374256;
    border: 1px solid #374256;
    font-family: PingFangSC-Regular;
    border-radius: 5px 5px 0 0;
    min-width: 95px;
    font-size: 14px;
    color: #8190A7;

    &:hover {
      background-color: #F2F2F2;
    }

    &[selected] {}
  }

  .el-button+.el-button {
    margin-left: 0;
  }
}
</style>
